/**
 * @ Author: luoqi
 * @ Create Time: 2024-07-26 23:45
 * @ Modified by: luoqi
 * @ Modified time: 2024-07-27 00:06
 * @ Description:
 */

#include "init.h"
#include "qshell/qterm.h"
#include "tasks/cli.h"
#include "tasks/blink.h"

static QCmdObj _cmd_fwupdate;
static int _cmd_fwupdate_hdl(int argc, char **argv);

static QCmdObj _cmd_reboot;
static int _cmd_reboot_hdl(int argc, char **argv);


void app_threadx_init(void)
{
    bsp_init();
    bsp_printf("\033[H\033[2J");
    bsp_printf("  ___  __  __       _             ____ \r\n");
    bsp_printf(" / _ \\|  \\/  | ___ | |_ ___  _ __|  _ \\ _ ____   __\r\n");
    bsp_printf("| | | | |\\/| |/ _ \\| __/ _ \\| '__| | | | '__\\ \\ / /\r\n");
    bsp_printf("| |_| | |  | | (_) | || (_) | |  | |_| | |   \\ V /\r\n");
    bsp_printf(" \\__\\_\\_|  |_|\\___/ \\__\\___/|_|  |____/|_|    \\_/\r\n");
    bsp_printf(" HXJC-RJTech, %s, %s\r\n", __DATE__, __TIME__);
    bsp_printf(" Designed by luoqi\r\n");
    blink_init();
    cli_init();
    qterm_attach(&_cmd_fwupdate, "fwupdate", _cmd_fwupdate_hdl, "firmware update");
    qterm_attach(&_cmd_reboot, "reboot", _cmd_reboot_hdl, "reboot system");
}

static int _cmd_fwupdate_hdl(int argc, char **argv)
{
    bsp_reboot();
    return 0;
}

static int _cmd_reboot_hdl(int argc, char **argv)
{
    bsp_reboot();
    return 0;
}
